home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2490 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  60 lines

  1. Path: comsearch.com!tnasca
  2. From: Thuan Nguyen <thnguyen@comsearch.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: A question about declaring/passing arrays of structures
  5. Date: 17 Jan 1996 22:48:47 GMT
  6. Organization: ComSearch, Inc
  7. Message-ID: <4djucf$ehi@gateway.comsearch.com>
  8. References: <4djhdc$kp3@kira.cc.uakron.edu>
  9. NNTP-Posting-Host: arcturus.comsearch.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (X11; I; SunOS 4.1.4 sun4c)
  14. X-URL: news:4djhdc$kp3@kira.cc.uakron.edu
  15.  
  16. tberg@dax.cc.uakron.edu (timothy a berg) wrote:
  17. >     I have recently been having trouble getting a program to work.  It
  18. >consists of 6 variables, which are all arrays of structures.  It seems
  19. >that when I pass them to a function, (located in another file), the
  20. >compiler will flag a fatal error on some of them.  They are all defined
  21. >properly in a '.h' file, and linked to from the main program file,
  22. >(containing the 'main' function).  There is nothing really unique about
  23. >the functions that work.  Most of them consist of a few character
  24. >variables, a few integers, and 5 of the 6 contain a character array, set
  25. >to a certain length by a constant.
  26. >     The error that I get is a 'General Protection Error' at 0001:3???,
  27. >which seems low in memory.  But, when I comment out a for-next loop
  28. >that is immediately after the function call, I get a 'Stack Fault' error
  29. >at ALMOST the same location.  I'm baffled.  I've had assembler, and
  30. >several programming courses, but this one puzzles me.
  31. >     Does anybody have a possible solution?  If so, e-mail PERSONALLY,
  32. >as I don't get to read the news often.  Your help is VERY MUCH
  33. >appreciated, as I have been trying to remedy this problem for almost 4
  34. >months now, with no success!!
  35. >
  36. >Tim Berg
  37. >
  38.  
  39. how about including this in the .h file
  40.  
  41. ..
  42. define your structure here
  43. ...
  44. #ifndef MAIN_BODY
  45. yours_tructure a;
  46. #else
  47. extern your_structure a;
  48. #endif
  49.  
  50. and in the main program 
  51.  
  52. #define MAIN_BODY
  53. #include <yours.h>
  54. #undef MAIN_BODY
  55.  
  56. main()
  57. {
  58. }
  59.  
  60.